import Http from "./request.js"; // 假设封装的方法在request.js文件中

const request = new Http();

// 封装请求方法
//
// 首页弹窗广告
export const getInfo = (params) =>
  request.get("/api/index/ad", params, {
    token: uni.getStorageSync("token"),
  });


// 用户登录
export const getWxLogin = (params) => request.post("/api/user/wxlogin", params);
//修改用户资料
export const editUserInfo = (params) =>
  request.post("/api/user/profile", params, {
    token: uni.getStorageSync("token"),
  });
//获取用户信息
export const getUserInfo = (params) =>
  request.get("/api/user/info", params, {
    token: uni.getStorageSync("token"),
  });
//发送验证码
export const sendCode = (params) => request.post("/api/sms/send", params);
//文件上传
export const uploadFile = (params) =>
  request.upload("/api/common/upload", params);

/* 首页 */
//基础信息
export const getHomeInit = (params) => request.get("/api/common/init", params);
//轮播图
export const getHomeBanner = (params) =>
  request.get("/api/index/banner", params);
//首页商品
export const getHomeGoods = (params) => request.get("/api/index/index", params);
//首页banner详情
export const getHomeBannerDetail = (params) =>
  request.get("/api/index/banner_detail", params);

//全局搜索
export const getSearch = (params) => request.get("/api/index/query", params);

/* 店铺  */
//店铺列表
export const getShopList = (params) => request.get("/api/shop/index", params);
//线下门店列表
export const getStoreList = (params) => request.get("/api/store/index", params);
//店铺信息
export const getShopInfo = (params) =>
  request.get("/api/shop/info", params, {
    token: uni.getStorageSync("token"),
  });
//店铺服务
export const getShopService = (params) =>
  request.get("/api/shop/service", params, {
    token: uni.getStorageSync("token"),
  });
//关注/取消关注店铺
export const followShop = (params) =>
  request.post("/api/shop/follow", params, {
    token: uni.getStorageSync("token"),
  });
//关注店铺列表
export const getFollowShopList = (params) =>
  request.get("/api/shop/followList", params, {
    token: uni.getStorageSync("token"),
  });
//收藏/取消收藏商品
export const collect = (params) =>
  request.post("/api/product/collect", params, {
    token: uni.getStorageSync("token"),
  });
//收藏商品列表
export const getCollectlist = (params) =>
  request.get("/api/product/collectlist", params, {
    token: uni.getStorageSync("token"),
  });
/* 商品 */
//商品列表
export const getGoodsList = (params) =>
  request.get("/api/product/lists", params);
//商品详情
export const getGoodsDetail = (params) =>
  request.get("/api/product/details", params);
//推荐商品列表
export const getRecommendList = (params) =>
  request.get("/api/product/recommend", params, {
    token: uni.getStorageSync("token"),
  });
//获取商品评论
export const getGoodsCommentList = (params) =>
  request.get("/api/product/comment", params, {
    token: uni.getStorageSync("token"),
  });
//分享商品
export const shareGoods = (params) =>
  request.post("/api/product/share", params, {
    token: uni.getStorageSync("token"),
    "Content-Type": "application/x-www-form-urlencoded",
  });

//商品评价
export const getGoodsComment = (params) =>
  request.post("/api/order/comment", params, {
    token: uni.getStorageSync("token"),
  });

//收藏/取消收藏商品
export const collectGoods = (params) =>
  request.post("/api/product/collect", params, {
    token: uni.getStorageSync("token"),
  });
//查询底价
export const getFloorPrice = (params) =>
  request.get("/api/product/lowest", params, {
    token: uni.getStorageSync("token"),
  });
//提交订单
export const submitOrder = (params) =>
  request.post("/api/order/addOrder", params, {
    token: uni.getStorageSync("token"),
  });
//取消订单
export const cancelOrder = (params) =>
  request.post("/api/order/cancelOrder", params, {
    token: uni.getStorageSync("token"),
  });
//购买会员
export const userBuy = (params) =>
  request.post("/api/user/buy", params, {
    token: uni.getStorageSync("token"),
  });

//操作购物车
export const handleCart = (params) =>
  request.post("/api/cart/storage", params, {
    token: uni.getStorageSync("token"),
    // "Content-Type": "application/x-www-form-urlencoded",
    // "Content-Type": "application/json",
  });
// 获取订单数量
export const getOrderCount = (params) =>
  request.get("/api/order/count", params, {
    token: uni.getStorageSync("token"),
  });
//获取订单列表
export const getOrderList = (params) =>
  request.get("/api/order/getOrderList", params, {
    token: uni.getStorageSync("token"),
  });
//获取订单详情
export const getOrderDetail = (params) =>
  request.get("/api/order/getOrderInfo", params, {
    token: uni.getStorageSync("token"),
  });
//获取购物车
export const getCartList = (params) =>
  request.post("/api/cart/synchro", params, {
    token: uni.getStorageSync("token"),
  });
//删除订单
export const delOrder = (params) =>
  request.post("/api/order/delOrder", params, {
    token: uni.getStorageSync("token"),
  });
//确认订单
export const confirmOrder = (params) =>
  request.post("/api/order/confirmReceipt", params, {
    token: uni.getStorageSync("token"),
  });
//订单评论
export const commentOrder = (params) =>
  request.post("/api/order/comment", params, {
    token: uni.getStorageSync("token"),
  });

//获取地址列表
export const getAddressList = (params) =>
  request.get("/api/address/getaddress", params, {
    token: uni.getStorageSync("token"),
  });
//添加地址
export const addAddress = (params) =>
  request.post("/api/address/address", params, {
    token: uni.getStorageSync("token"),
  });
//删除地址
export const delAddress = (params) =>
  request.post("/api/address/deladdress", params, {
    token: uni.getStorageSync("token"),
  });
//获取分类
export const getCategory = (params) =>
  request.get("/api/index/category", params, {
    token: uni.getStorageSync("token"),
  });
//获取分类商品
export const getCateGoods = (params) =>
  request.get("/api/index/cateGoods", params, {
    token: uni.getStorageSync("token"),
  });

//获取支付信息
export const getPayInfo = (params) =>
  request.post("/api/pay/info", params, {
    token: uni.getStorageSync("token"),
  });
//支付订单
export const payOrder = (params) =>
  request.post("/api/pay/payment", params, {
    token: uni.getStorageSync("token"),
  });

//获取支付详情
export const getPayDetail = (params) =>
  request.get("/api/pay/details", params, {
    token: uni.getStorageSync("token"),
  });

//提交留言
export const submitMessage = (params) =>
  request.post("/api/feedback/add", params, {
    token: uni.getStorageSync("token"),
  });

//提交代购
export const purchasingAdd = (params) => {
  return request.post("/api/purchasing/add", params, {
    token: uni.getStorageSync("token"),
  });
};

// 门诊
//门诊列表
export const getHospitalList = (params) =>
  request.get("/api/hospital/index", params);

//门诊详情
export const getHospitalDetail = (params) =>
  request.get("/api/hospital/detail", params);

//门诊咨询
export const getHospitalConsult = (params) =>
  request.post("/api/hospital/consult", params, {
    token: uni.getStorageSync("token"),
  });

//分销
//直推成员列表
export const getDirectList = (params) =>
  request.get("/api/user/distribution", params, {
    token: uni.getStorageSync("token"),
  });
//提现记录
export const getWithdrawList = (params) =>
  request.get("/api/withdrawal/index", params, {
    token: uni.getStorageSync("token"),
  });

//发起提现申请
export const withdrawApply = (params) => {
  return request.post("/api/withdrawal/apply", params, {
    token: uni.getStorageSync("token"),
  });
};

//会员数据
export const getVip = ()=>{
	return request.get("/api/index/vip")
}

// 物流信息
export const getLogistics = (params)=>{
	return request.get("/api/order/logistics",params,{
		token: uni.getStorageSync("token"),
	})
}